import React from 'react'
import { Link } from 'react-router-dom'
import { get } from '../../../axios'
import history from '../../../history'

class Profile extends React.Component {
    constructor(props) {
        super(props)
        this.state = {
            userInfo: {}
        }
    }

    componentDidMount() {
        let user_id = this.props.match.params.user_id
        get(`mem/user-info/${user_id}`).then(resp => {
            if (resp.success) {
                this.setState({userInfo: resp.data})
            }
        })
    }

    render() {
        const {userInfo} = this.state
        return(
            <div class="my margin">
                <div class="head">
                    <div class="photo">
                        <p><img src={userInfo.avatar} /></p>
                        <p>{userInfo.nickname}</p>
                    </div>
                </div>
                <div class="container">
                    <div class="mid clearfix">
                        <div class="row">
                            <div class="col-xs-4">
                                <div class="p1">{userInfo.rank}</div>
                                <div class="p2">评分</div>
                            </div>
                            <div class="col-xs-4" onClick={()=>history.push('/project-profit')}>
                                <div class="p1">{userInfo.income}</div>
                                <div class="p2">项目收益</div>
                            </div>
                            <div class="col-xs-4" onClick={()=>history.push('/point')}>
                                <div class="p1">{userInfo.point}</div>
                                <div class="p2">积分</div>
                            </div>
                        </div>
                    </div>
                    <div className="btns">
                        <Link to={`/contacts/detail/${this.props.match.params.user_id}`} className="contact">联系</Link>
                    </div>
                </div>
            </div>
        )
    }
}


  
export default Profile